//
//  JBSystemInfo.m
//  SystemInfo
//
//  Created by YongbinZhang on 10/9/13.
//  Copyright (c) 2013 YongbinZhang. All rights reserved.
//

#import "JBSystemInfo.h"


#ifndef __IPHONE_8_0
#define __IPHONE_8_0 80000
#endif

//  用四位整数表示当前系统版本号
static int currentSystemVersion = -1;

//  状态栏高度
float const StatusBarHeight = 20.0f;

//  导航条高度
float const NavitationBarHeight = 44.0f;

//  TabBar的高度
float const TabBarHeight = 49.0f;

//  ToolBar的高度
float const ToolBarHeight = 44.0f;

@implementation JBSystemInfo

//  当前设备类型
+ (NSString *)currentDeviceModel
{
    return [UIDevice currentDevice].model;
}

//  当前系统版本
+ (NSString *)currentSystemVersion
{
    return [UIDevice currentDevice].systemVersion;
}

//  设备编号
+ (NSString *)currentDeviceUUID
{
    if ([self currentSystemVersionBelowiOS6]) {
        return @"";
    } else {
        return [UIDevice currentDevice].identifierForVendor.UUIDString;
    }
}

@end


@implementation JBSystemInfo (iOS)


//////////////////iOS5/////////////////////

//  系统版本是否是iOS5
+ (BOOL)currentSystemVersionIsiOS5
{
    if (currentSystemVersion < 0) {
        currentSystemVersion = (int)([self currentSystemVersion].floatValue * 10000);
    }

    return (currentSystemVersion >= __IPHONE_5_0 && currentSystemVersion < __IPHONE_6_0);
}

//  系统版本是否小于iOS5
+ (BOOL)currentSystemVersionBelowiOS5
{
    if (currentSystemVersion < 0) {
        currentSystemVersion = (int)([self currentSystemVersion].floatValue * 10000);
    }
    
    return currentSystemVersion < __IPHONE_5_0;
}

//  系统版本是否大于iOS5
+ (BOOL)currentSystemVersionAboveiOS5
{
    if (currentSystemVersion < 0) {
        currentSystemVersion = (int)([self currentSystemVersion].floatValue * 10000);
    }
    
    return currentSystemVersion >= __IPHONE_6_0;
}


//////////////////iOS6/////////////////////

//  系统版本是否是iOS6
+ (BOOL)currentSystemVersionIsiOS6
{
    if (currentSystemVersion < 0) {
        currentSystemVersion = (int)([self currentSystemVersion].floatValue * 10000);
    }
    
    return (currentSystemVersion >= __IPHONE_6_0 && currentSystemVersion < __IPHONE_7_0);
}

//  系统版本是否小于iOS6
+ (BOOL)currentSystemVersionBelowiOS6
{
    if (currentSystemVersion < 0) {
        currentSystemVersion = (int)([self currentSystemVersion].floatValue * 10000);
    }
    
    return currentSystemVersion < __IPHONE_6_0;
}

//  系统版本是否大于iOS6
+ (BOOL)currentSystemVersionAboveiOS6
{
    if (currentSystemVersion < 0) {
        currentSystemVersion = (int)([self currentSystemVersion].floatValue * 10000);
    }
    
    return currentSystemVersion >= __IPHONE_7_0;
}


//////////////////iOS7/////////////////////

//  系统版本是否是iOS7
+ (BOOL)currentSystemVersionIsiOS7
{
    if (currentSystemVersion < 0) {
        currentSystemVersion = (int)([self currentSystemVersion].floatValue * 10000);
    }
    
    return (currentSystemVersion >= __IPHONE_7_0 && currentSystemVersion < __IPHONE_8_0);
}

//  系统版本是否小于iOS7
+ (BOOL)currentSystemVersionBelowiOS7
{
    if (currentSystemVersion < 0) {
        currentSystemVersion = (int)([self currentSystemVersion].floatValue * 10000);
    }
    
    return currentSystemVersion < __IPHONE_7_0;
}

//  系统版本是否大于iOS7
+ (BOOL)currentSystemVersionAboveiOS7
{
    if (currentSystemVersion < 0) {
        currentSystemVersion = (int)([self currentSystemVersion].floatValue * 10000);
    }
    
    return currentSystemVersion >= __IPHONE_8_0;
}

@end



@implementation JBSystemInfo (Size)

+ (CGFloat)screenWidth
{
    return [UIScreen mainScreen].bounds.size.width;
}

+ (CGFloat)screenHeight
{
    return [UIScreen mainScreen].bounds.size.height;
}

@end
